package com.jspm.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.jspm.dao.GupiaobankuaiDao;
import com.jspm.entity.GupiaobankuaiEntity;
import com.jspm.entity.view.GupiaobankuaiView;
import com.jspm.entity.vo.GupiaobankuaiVO;
import com.jspm.service.GupiaobankuaiService;
import com.jspm.utils.PageUtils;
import com.jspm.utils.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service("gupiaobankuaiService")
//@Transactional // 添加事务注解
public class GupiaobankuaiServiceImpl extends ServiceImpl<GupiaobankuaiDao, GupiaobankuaiEntity> implements GupiaobankuaiService {

	@Autowired
	private GupiaobankuaiDao gupiaobankuaiDao;

    @Override
	@Transactional(propagation = Propagation.REQUIRED, readOnly = true) // 只读事务
    public PageUtils queryPage(Map<String, Object> params) {
        Page<GupiaobankuaiEntity> page = this.selectPage(
                new Query<GupiaobankuaiEntity>(params).getPage(),
                new EntityWrapper<GupiaobankuaiEntity>()
        );
        return new PageUtils(page);
    }
    
    @Override
	@Transactional(propagation = Propagation.REQUIRED, readOnly = true) // 只读事务
	public PageUtils queryPage(Map<String, Object> params, Wrapper<GupiaobankuaiEntity> wrapper) {
		  Page<GupiaobankuaiView> page =new Query<GupiaobankuaiView>(params).getPage();
	        page.setRecords(gupiaobankuaiDao.selectListView(page,wrapper));
	    	PageUtils pageUtil = new PageUtils(page);
	    	return pageUtil;
 	}
    
    @Override
	@Transactional(propagation = Propagation.REQUIRED, readOnly = true) // 只读事务
	public List<GupiaobankuaiVO> selectListVO(Wrapper<GupiaobankuaiEntity> wrapper) {
 		return gupiaobankuaiDao.selectListVO(wrapper);
	}
	
	@Override
	@Transactional(propagation = Propagation.REQUIRED, readOnly = true) // 只读事务
	public GupiaobankuaiVO selectVO(Wrapper<GupiaobankuaiEntity> wrapper) {
 		return gupiaobankuaiDao.selectVO(wrapper);
	}
	
	@Override
	@Transactional(propagation = Propagation.REQUIRED, readOnly = true) // 只读事务
	public List<GupiaobankuaiView> selectListView(Wrapper<GupiaobankuaiEntity> wrapper) {
		return gupiaobankuaiDao.selectListView(wrapper);
	}

	@Override
	@Transactional(propagation = Propagation.REQUIRED, readOnly = true) // 只读事务
	public GupiaobankuaiView selectView(Wrapper<GupiaobankuaiEntity> wrapper) {
		return gupiaobankuaiDao.selectView(wrapper);
	}


}
